<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: gaoluo
 * @Date: 2022-05-05 14:48:58
 * @LastEditors: gaoluo
 * @LastEditTime: 2022-07-25 19:28:55
 * @FilePath: /vue3.0-vite-ts-xiaotuxian/src/views/home/index.vue
-->
<template>
  <div class="container">
    <input type="text" v-model="username" />
    <input type="passwork" v-model="password" />
    <button @click="onLogin">登录</button>
    <div>{{ $aaa }}</div>
    <span v-pre>{{ this will not be compiled }}</span>
    <p>{{ a }}</p>
    <Model></Model>
    <van-nav-bar></van-nav-bar>
  </div>
</template>

<script setup lang="ts">
import { getToken } from "@/api/login";
import { useStore } from "@/stores/index";
import { ref, getCurrentInstance, ComponentInternalInstance } from "vue";

const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const username = ref("");
const password = ref("");

const a = $computed(() => username.value);

const store = useStore();

const onLogin = () => {
  getToken({
    uakey: "2839nddks2sk",
  }).then((res) => {
    store.$patch({
      token: res.data.token,
    });
  });
};
</script>

<style scoped lang="less">
.container {
  display: flex;
  flex-direction: column;
  input,
  button,
  div {
    margin-top: 10px;
  }
}
</style>
